package net.qhzw.admin.controller;

import net.qhzw.admin.param.MechanismParam;
import net.qhzw.admin.query.MechanismQuery;
import net.qhzw.admin.service.SysMechanismService;
import net.qhzw.common.model.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("sys/mechanism")
public class SysMechanismController {


    @Autowired
    private SysMechanismService mechanismService;


    /****
     * 根据id获取当前机构信息
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public JsonResult getMechanism(@PathVariable(value = "id") String id) {
        return mechanismService.getMechanism(id);
    }


    /***
     * 获取当前机构信息列表
     * @param query
     * @return
     */
    @GetMapping
    public JsonResult getMechanismList(MechanismQuery query) {
        return mechanismService.getMechanismList(query);
    }

    /***
     * 添加机构信息
     * @param param
     * @return
     */
    @PostMapping
    public JsonResult addMechanism(@RequestBody MechanismParam param) {
        return mechanismService.editMechanism(param);
    }


    /***
     * 修改机构信息
     * @param param
     * @return
     */
    @PutMapping
    public JsonResult modifyMechanism(@RequestBody MechanismParam param) {
        return mechanismService.editMechanism(param);
    }



    /***
     * 删除机构
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public JsonResult deleteMechanism(@PathVariable(value = "id") String id) {
        return mechanismService.deleteMechanism(id);
    }


}
